package xzl.edu.cn.set;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class ComputerManager {
	Map<String, Computer> computermap;
	public ComputerManager() {
		this.computermap=new HashMap<String,Computer>();
	
	}
	/**
	 * 添加computer
	 */
	public void addcomputer() {
	 Computer c1=new Computer("联想",6000.0,15.6);
	 Computer c2=new Computer("戴尔", 7000.0,14.0);
     Computer c3=new Computer("小米", 8000.0, 13.3);
     computermap.put("01", c1);
     computermap.put("02", c2);
     computermap.put("03", c3);
	}
	/**
	 * 遍历所有computer
	 * @return
	 */
	public void showcomputer() {
		Logger logger=LogManager.getLogger(ComputerManager.class); 
		Set<String>keyset=computermap.keySet();
		for(String comId:keyset) {
			Computer computer=computermap.get(comId);
			if(computer!=null) {
				logger.info(computer.toString());
			}
		}
	}
	/**
	 * 查找编号为ID的computer
	 * @param id
	 * @return
	 */
	public Computer Search(String id) {
		return computermap.get(id);
	}
}
